<?php include_once "top.php";
$stime=strtotime($_GET['sdate']);
$etime=strtotime($_GET['edate'])+86400;
$where='1';
if($stime && $etime){
	$where.=(' and create_time >= '.$stime.' and create_time < '.$etime);
}else{
	$where.=(' and create_time >= '.strtotime(date('Y-m-d',time())).' and create_time < '.strtotime(date('Y-m-d',time()+86400)));
}
$where.=' order by id desc';
?>
<div class="addleft">
	<a href="products.php">商品列表</a>
	<a href="product_edit.php">添加商品</a>
	<a href="ex_record.php">兑换记录(卡券)</a>
	<a href="ex_record2.php">兑换记录(实物)</a>
</div>
<div class="addbar">
	<ul>
	<h2 style="float:left">虚拟商品兑换记录</h2>
	<div style="float:left;margin:20px 0 0 20px">
		<form action="ex_record.php" method="get" onsubmit="return checkForm()">
		<input id="sdate" type="text" name="sdate" value="<?php echo $_GET['sdate']?$_GET['sdate']:date('Y-m-d',time())?>" class="laydate-icon ipt" onclick="laydate()" placeholder="选择开始日期" style="width:150px" /> -
		<input id="edate" type="text" name="edate" value="<?php echo $_GET['edate']?$_GET['edate']:date('Y-m-d',time())?>" class="laydate-icon ipt" onclick="laydate()" placeholder="选择结束日期" style="width:150px" />
		<input type="submit" name="sub_sch" value="查找" />
		<input type="button" name="" value="全部" onclick="location='ex_record.php'" />
		</form>
	</div>
	
	<li class="lihd"><strong align="center">
		<label style="width:60px">ID</label>
		<label style="width:120px">用户姓名</label>
		<label style="width:150px">商品名称</label>
		<label style="width:150px">卡券账号</label>
		<label style="width:200px">卡券密码</label>
		<label style="width:60px">面值</label>
		<label style="width:150px">兑换时间</label>
		</strong>
	</li>
	<?php 
	foreach($db->ig2_select('mae_shop_user_exchange_list',$where) as $list){
		$user=$db->ig2_want('mae_user','id='.$list['uid']);
		$prize=$db->ig2_want('mae_prize','id='.$list['prize_id']);
		$virtual=$db->ig2_want('mae_prize_virtual','id='.$list['virtual_id']);
	?>
	<li align="center">
		<label style="width:60px"><?php echo $list['id']?></label>
		<label style="width:120px"><?php echo $user?$user['name']:'该店员已被删除'?></label>
		<label style="width:150px"><?php echo $prize['name']?></label>
		<label style="width:150px"><?php echo $virtual?$virtual['cardnum']:'-'?></label>
		<label style="width:200px"><?php echo $virtual?$virtual['password']:'-'?></label>
		<label style="width:60px"><?php echo $virtual?$virtual['par']:'-'?></label>
		<label style="width:150px"><?php echo date('Y-m-d H:i:s',$list['create_time'])?></label>
	</li>
	<?php }?>
	</ul>
</div>
<script language="javascript">
function trim(str){
	return str.replace(/(^\s*)|(\s*$)/g, "");
}
function checkForm(){
	var sdate=trim($('#sdate').val());
	var edate=trim($('#edate').val());
	if(sdate!='' && edate==''){
		alert('请选择结束日期');
		return false;
	}
	if(edate!='' && sdate==''){
		alert('请选择开始日期');
		return false;
	}
	return true;
}
</script>
<?php include_once "down.php";?>